package com.lcc.generate;

/**
 * @author lcc
 * @date 2025/5/21 9:59
 */
public class StringBuilder2 {

    private StringBuilder sb = new StringBuilder();

    public StringBuilder2() {
    }

    public StringBuilder2(String str) {
        sb.append(str);
    }

    public StringBuilder2 append(String str) {
        sb.append(str);
        return this;
    }

    public StringBuilder2 replace(String str,String newStr) {
        int i = sb.indexOf(str);
        while (i != -1){
            sb.replace(sb.indexOf(str),sb.indexOf(str)+str.length(),newStr);
            i = sb.indexOf(str);
        }
        return this;
    }

    public StringBuilder2 replace(int start,int end,String newStr){
        sb.replace(start,end,newStr);
        return this;
    }

    public StringBuilder2 delete(int start,int end){
        sb.delete(start,end);
        return this;
    }

    public String toString() {
        return sb.toString();
    }

    public int length() {
        return sb.length();
    }


    public int indexOf(String str) {
        return sb.indexOf(str);
    }
}
